package com.ag.admin;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;

import com.ag.admin.dao.AdminTbUserDAO;
import com.ag.admin.service.impl.UserServiceImpl;
import com.ag.bean.TbRole;
import com.ag.bean.TbUser;
import com.ag.common.BaseTest;
import com.ag.dao.TbRoleDAO;

public class UserService extends BaseTest {
	private static final Logger logger = Logger.getLogger(UserService.class);

	@Resource(name = "userServiceImpl")
	private UserServiceImpl userServiceImpl;
//	@Resource(name = "adminTbUserDAO")
//	private AdminTbUserDAO userDAO;
	@Resource(name = "adminTbUserDAO")
	private AdminTbUserDAO userDAO;
	@Resource(name = "TbRoleDAO")
	private TbRoleDAO roleDAO;
	
	@Test
	@Ignore
	public void checkUId() {
		//Boolean b = this.userServiceImpl.checkUId("温镇澎");
		//logger.info(b);
	}
	@Test
	public void findById(){
		TbUser user = this.userServiceImpl.findById("vb");
		logger.info(user);
	}
	
	@Test
	@Ignore
	public void queryUser(){
		String s = "select distinct u from TbUser u " +
				"join fetch u.tbUserRoles ur " +
				"join fetch ur.tbRole r " +
				"where u.a = 0 ";
		int total = this.userDAO.queryCount(s).size();
		logger.info("total = "+total);
	}
	
	@Test
	@Ignore
	public void save(){
		TbRole  role = this.roleDAO.findById("1001");
		logger.info("role"+ role.getRId());
		logger.info("rolename"+role.getRName());
		TbUser user = new TbUser();
		user.setUId("ww45");
		user.setUName("good");
		user.setUPassword("123");
		//this.userServiceImpl.save(user, "1001");
	}
}
